package types

import (
	"github.com/golang-jwt/jwt/v4"
	"news/pkg/models"
	"time"
)

type UserRegisterForm struct {
	baseForm

	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
	HeadImg  string `json:"headImg" form:"headImg"`
	Age      int    `json:"age" form:"age" binding:"required"`
	Sex      int    `json:"sex" form:"sex" binding:"required"`
	Role     string `json:"role" form:"role"`
	Desc     string `json:"desc" form:"desc"`
}

type UserLoginForm struct {
	baseForm

	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
}

type UsersDeleteForm struct {
	baseForm
	UserIds []models.Id `json:"userIds" form:"userIds"`
}

type UpdateUserForm struct {
	baseForm
	Role     string    `json:"role" form:"role" swaggerignore:"true"`
	Password string    `json:"password" form:"password" swaggerignore:"true"`
	UserId   models.Id `json:"id" form:"id" swaggerignore:"true"`
	HeadImg  string    `json:"headImg" form:"headImg" binding:"required"`
	Age      int       `json:"age" form:"age" binding:"required"`
	Sex      int       `json:"sex" form:"sex" binding:"required"`
	Desc     string    `json:"desc" form:"desc"`
}

type UpdateUserPassword struct {
	baseForm
	UserId  models.Id `json:"id" form:"id" swaggerignore:"true"`
	OldPass string    `json:"oldPass" form:"oldPass" binding:"required"`
	NewPass string    `json:"newPass" form:"oldPass" binding:"required"`
}

type AdminUpdate struct {
	baseForm
	UserId   models.Id `json:"id" form:"id" swaggerignore:"true"`
	Role     string    `json:"role" form:"role"`
	Password string    `json:"password" form:"password"`
}
type DeleteUserForm struct {
	baseForm
	UserId models.Id `json:"id" form:"id" binding:"required"`
}

type UserTokenClaims struct {
	jwt.StandardClaims

	UserId   models.Id `json:"userId"`
	UserName string    `json:"userName"`
}

type UserLoginResp struct {
	User  GetUserResp `json:"user"`
	Token string      `json:"token"`
}

type GetUserResp struct {
	Id        models.Id `json:"id"`
	CreatedAt time.Time `json:"createTime"`
	Username  string    `json:"username"`
	Password  string    `json:"-"`
	Role      string    `json:"role"`
	HeadImg   string    `json:"headImg"`
	Age       int       `json:"age"`
	Sex       int       `json:"sex"`
	Desc      string    `json:"desc"`
}

type SearchUserForm struct {
	pageForm

	Q string `json:"q" form:"q"` // 查询关键字
}

type GetUserForm struct {
	baseForm

	Id models.Id `uri:"id"`
}

type PassUpdateResp struct {
	baseForm
	Id       models.Id `json:"id"`
	Username string    `json:"username"`
	Role     string    `json:"role"`
}
